<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>登录系统</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet" href="__STATIC__/lib/bootstrap/3.3.7/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="__STATIC__/lib/font-awesome/css/font-awesome.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="__STATIC__/lib/adminlte/css/AdminLTE.min.css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body class="hold-transition login-page">
<div class="login-box">
    <div class="login-logo">
        <a href="#"><b>Admin</b>LTE</a>
    </div>
    <!-- /.login-logo -->
    <div class="login-box-body">
        <p class="login-box-msg">登录以开始操作</p>

        <form>
            <div class="form-group has-feedback">
                <input type="text" class="form-control" placeholder="用户名" name="username" value="" autofocus required>
                <span class="glyphicon glyphicon-user form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input type="password" class="form-control" placeholder="密码" name="password" value="" required>
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <div class="row">
                <div class="col-xs-4">
                    <button id="login" type="button" class="btn btn-primary btn-block btn-flat">登录</button>
                </div>
                <!-- /.col -->
            </div>
        </form>
        <hr>
        <a href="#">忘记密码？</a><br>

    </div>
    <!-- /.login-box-body -->
</div>
<!-- /.login-box -->

<!-- jQuery 3 -->
<script src="__STATIC__/lib/jquery/3.2.1/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="__STATIC__/lib/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- layer -->
<script src="__STATIC__/lib/layer/layer.js"></script>
<script>
    $("#login").click(function () {

        var username = $("input[name='username']");
        var password = $("input[name='password']");

        $.ajax({
            type: 'POST',
            url: "{:url('admin/login/doLogin')}",
            data: {
                username: username.val(),
                password: password.val(),
            },
            success: function (data) {
                layer.closeAll();
                if (data.code === 1) {
                    layer.msg("登录成功，正在跳转", {icon: 6});
                    window.location.href = data.url;
                } else {
                    layer.msg(data.msg, {icon: 5});
                }

            }
        });

    })
</script>
</body>
</html>
